package com.yzl.frelink.entities.chart;

import lombok.Data;

@Data
public class Transition {
    StateTreeNode from; // which State trans from
    StateTreeNode to;  // which State trans to

    int[][] position;
    
    String event; 
    String guard; 
    String action;

    public Transition(StateTreeNode from, StateTreeNode to) {
        this.from = from;
        this.to = to;
    }

    public String getMatlabLabel() {
        StringBuilder label = new StringBuilder();
        label.append("\"");
        if (event != null && !event.isEmpty()) {
            label.append(event);
        }
        if (guard != null && !guard.isEmpty()) {
            label.append("[").append(guard).append("]");
        }
        if (action != null && !action.isEmpty()) {
            label.append("{").append(action).append("}");
        }
        label.append("\"");
        return label.toString();
    }

    public String getAntiGuard() {
        if (guard == null || guard.isEmpty()) {
            return null;
        }
        return "~(" + guard + ")";
    }
}